home *** CD-ROM | disk | FTP | other *** search
- #include "stdtyp.h"
- #include <<stdio.h>>
-
- void main(SHORT argc, CHAR *argv[])
- {
- FILE *f1_ptr, *f2_ptr; /* sequential files */
- SHORT choice; /* number of the sort */
-
- /*--------- Open input files for reading and writing -------------- */
-
- f1_ptr = fopen(argv[1],"rw");
- f2_ptr = fopen(argv[2],"rw");
-
- if ( f1_ptr EQ NULL) /* check first file is opened */
- {
- printf("\n Cannot open output file 1 %s",argv[1]);
- exit(0);
- }
- if ( f2_ptr EQ NULL ) /* check second file is opened */
- {
- printf("\n Cannot open output file 2 %s",argv[2]);
- exit(0);
- }
-
- /*------- Menu : choose the sort -----------------------------------------*/
-
- printf("1. Bubble sort\n");
- printf("2. Quick sort \n");
- printf("3. Merge sort\n");
-
- scanf("%d",&choice");
-
- /*--------- Sort the files -----------------------------------------------------------*/
-
- switch(choice)
- {
- case 1 :
- bub_sort(f1_ptr,f2_ptr); /* bubble sort */
- break;
- case 2:
- qck_sort(f1_ptr,f2_ptr); /* quick sort */
- break;
- case 3:
- mg_sort(f1_ptr,f2_ptr); /* merge sort */
- break;
- default:
- printf("Error");
- }
- fclose(f1_ptr); /* Close files */
- fclose(f2_ptr);
- }
-
-
-
-
-